<template>
  <div class="examMade">
    <Card>
      <Form ref="queryForm" :model="queryForm" :rules="roleValidate" style="display: block;">
        <Row gutter="50">
          <!-- <i-col
            span="3"
            style="height:30px; line-height:30px; color:rgba(80, 80, 80, 1); margin-right: -60px;"
          >条件筛选：</i-col> -->
          <i-col span="5">
            <FormItem prop="managecome">
              <Cascader change-on-select :data="organizationList" v-model="queryForm.managecome" @on-change="organizationChange" placeholder="续期专员机构" clearable></Cascader>
            </FormItem>
          </i-col>
          <i-col span="5" class="code-LC">
            <FormItem prop="reagentCode">
              <Select v-model="queryForm.reagentCode" placeholder="续期专员姓名" clearable multiple>
                <Option
                  v-for="item in reagentNameList"
                  :key="item.key"
                  :value="item.key"
                >{{item.value}}-{{item.key}}</Option>
              </Select>
            </FormItem>
          </i-col>
          <i-col span="5">
            <FormItem prop="workNews">
              <Select v-model="queryForm.workNews" clearable placeholder="工作类型">
                <Option v-for="item in newsList" :key="item.key" :value="item.key">{{item.value}}</Option>
              </Select>
            </FormItem>
          </i-col>
          <i-col span="5">
            <FormItem prop="workDate">
              <DatePicker
                type="daterange"
                placement="bottom-end"
                placeholder="工作日期起止期"
                clearable
                v-model="queryForm.workDate"
                @on-change="workDateChange"
                style="width: 100%"
              ></DatePicker>
            </FormItem>
          </i-col>
        </Row>
        <Row>
          <i-col span="12">
            <FormItem>
              <Button type="primary" @click="submitForm" :loading="queryLoading">查询</Button>
              <Button class="resetForm" @click="resetForm" style="margin: 0 20px;">重置</Button>
              <Button type="primary" @click="downLoad1()" :disabled="evaluationList.length==0">批量导出</Button>
            </FormItem>
          </i-col>
        </Row>
      </Form>
      <Row>
        <i-col span="20">
          <span>工作类型：</span>
          <Button :type="btn[0]" @click="buttonClick(0)" class="statusButton">全部</Button>
          <Button :type="btn[1]" @click="buttonClick(1)" class="statusButton statusButton2">未回销</Button>
          <Button
            :type="btn[2]"
            @click="buttonClick(2)"
            class="statusButton"
            style="width:96px;"
          >已回销</Button>
        </i-col>
      </Row>
    </Card>

    <!-- 评价列表 -->
    <Row style="margin-top:20px" class="listgroup">
     
      <div v-for="(item,index) in evaluationList" :key="index" @click="logDetail(item,index)">
        <i-col span="6" class="examCard">
          <Card style="width:85%;" shadow>
            <div slot="extra">
              <div
                :class="item.status=='未回销'|| item.status=='重新回销'?'cardExtra cardExtra1':'cardExtra cardExtra2'"
              >{{item.status=='未回销' || item.status=='重新回销'?'未回销':'已回销'}}</div>
              <div :class="item.status=='未回销'?'dropright dropright1':'dropright dropright2'">
                <Icon type="md-arrow-dropright" />
              </div>
            </div>

            <div class="cardStyle">
              <Row>
                <i-col span="22">
                  <div class="cardTitle">工作类型：{{item.workType}}</div>
                </i-col>
                <!-- ''：未评价，0：未读，1：已读 -->
                <i-col
                  span="2"
                  style="font-size:22px; margin-top: -6px;"
                  :class="item.isRead == '0'?'tRed':''"
                  v-if="item.isRead != ''"
                >
                  <Icon type="md-alert" />
                </i-col>
              </Row>
              <div class="cardContent">
                <div>
                  <Icon type="ios-time" class="cardIcon" />
                  工作时间：{{item.makeDay}} {{item.makeTime}}
                </div>
                <!-- <div class="cardFile">
                  <Icon type="ios-pin" class="cardIcon" />
                  工作地点：{{item.workSite}}
                </div>
                <div class="cardFile">
                  <Icon type="ios-checkbox" class="cardIcon" />
                  工作内容：{{item.expectEffect}}
                </div>
                <div class="cardFile">
                  <Icon type="ios-document" class="cardIcon" />
                  <span>{{item.smallFile}}</span>
                </div> -->
                <div>
                  计划面访保单{{item.detailNum ? item.detailNum.plantalkcount : 0}}张，已面访{{item.detailNum ? item.detailNum.donetalkcount : 0}}张
                </div>
                <div>
                  计划电访保单{{item.detailNum ? item.detailNum.planphonecount : 0}}张，已电访{{item.detailNum ? item.detailNum.donephonecount : 0}}张
                </div>
                <div>
                  计划短信保单{{item.detailNum ? item.detailNum.planmessagecount : 0}}张，已短信{{item.detailNum ? item.detailNum.donemessagecount : 0}}张
                </div>
                <div>
                  计划网络联系保单{{item.detailNum ? item.detailNum.plannetcount : 0}}张，已网络联系{{item.detailNum ? item.detailNum.donenetcount : 0}}张
                </div>
              </div>
            </div>
          </Card>
          <div class="cardFoot">发起人：{{item.name}}</div>
        </i-col>
      </div>
    </Row>
    <!-- 翻页 -->
    <div style="margin-right:50px;">
      <Page
        :total="total"
        :current="pageIndex"
        show-total
        :page-size="pageSize"
        @on-change="pageChange"
        style="text-align:right;margin-bottom:30px;"
      />
    </div>

    <!-- 详情————未回销 -->
    <Modal v-model="modal1" :transfer="false"   footer-hide="true" :mask-closable="false" width="680px" class="edModal" @on-cancel="cancelWin()">
      <div slot="header" class="draftTitle">工作日志详情</div>
      <Row style="margin-bottom:20px; margin-top:10px;">
        <i-col span="4" class="user-title" style="margin-right:10px;">{{infoList.name}}</i-col>
        <i-col span="4" class="user-list">
          <Icon type="md-browsers" />
          {{infoList.employeeNO}}
        </i-col>
        <i-col span="4" class="user-list">
          <Icon type="md-person" />
          {{infoList.roleName}}
        </i-col>
        <i-col span="10" class="user-list">
          <Icon type="ios-pin" />
          {{infoList.managecomName}}
        </i-col>
      </Row>
      <div class="ar-title">工作日志制定详情:</div>
      <div style="width:100%; margin:0 0 20px 60px;">
        <Row style="margin-bottom:20px; margin-top:20px;">
          <i-col span="3">工作类型：</i-col>
          <i-col span="12">
            <div>{{revokeList1.workType}}</div>
          </i-col>
        </Row>
        <Row style="margin-bottom:20px;">
          <i-col span="3">工作时间：</i-col>
          <i-col span="12">
            <div>{{revokeList1.makeDay}} {{revokeList1.makeTime}}</div>
          </i-col>
        </Row>
        <Row style="margin-bottom:20px;">
          <i-col span="3">电访情况：</i-col>
          <i-col span="12">
            <div>
              <span>计划{{revokeList1.detailNum ? revokeList1.detailNum.planphonecount : 0}}单-完成{{revokeList1.detailNum ? revokeList1.detailNum.donephonecount : 0}}单-超期{{revokeList1.detailNum ? revokeList1.detailNum.delayphonecount : 0}}单</span>
              <Button type="primary" size="small" style="margin-left:5px;" @click="linkToWorkRecord(revokeList1,'0')">工作记录</Button>
            </div>
          </i-col>
        </Row>
        <Row style="margin-bottom:20px;">
          <i-col span="3">面访情况：</i-col>
          <i-col span="12">
            <div>
              <span>计划{{revokeList1.detailNum ? revokeList1.detailNum.plantalkcount : 0}}单-完成{{revokeList1.detailNum ? revokeList1.detailNum.donetalkcount : 0}}单-超期{{revokeList1.detailNum ? revokeList1.detailNum.delaytalkcount : 0}}单</span>
              <Button type="primary" size="small" style="margin-left:5px;" @click="linkToWorkRecord(revokeList1,'1')">工作记录</Button>
            </div>
          </i-col>
        </Row>
        <Row style="margin-bottom:20px;">
          <i-col span="3">短信情况：</i-col>
          <i-col span="12">
            <div>
              <span>计划{{revokeList1.detailNum ? revokeList1.detailNum.planmessagecount : 0}}单-完成{{revokeList1.detailNum ? revokeList1.detailNum.donemessagecount : 0}}单-超期{{revokeList1.detailNum ? revokeList1.detailNum.delaymessagecount : 0}}单</span>
              <Button type="primary" size="small" style="margin-left:5px;" @click="linkToWorkRecord(revokeList1,'2')">工作记录</Button>
            </div>
          </i-col>
        </Row>
        <Row style="margin-bottom:20px;">
          <i-col span="3">网络情况：</i-col>
          <i-col span="12">
            <div>
              <span>计划{{revokeList1.detailNum ? revokeList1.detailNum.plannetcount : 0}}单-完成{{revokeList1.detailNum ? revokeList1.detailNum.donenetcount : 0}}单-超期{{revokeList1.detailNum ? revokeList1.detailNum.delaynetcount : 0}}单</span>
              <Button type="primary" size="small" style="margin-left:5px;" @click="linkToWorkRecord(revokeList1,'3')">工作记录</Button>
            </div>
          </i-col>
        </Row>
        <Row style="margin-bottom:20px;">
          <i-col span="3">续期情况：</i-col>
          <i-col span="12">
            <div>
              <span>收费成功{{revokeList1.detailNum ? revokeList1.detailNum.donefeecount : 0}}单</span>
              <Button type="primary" size="small" style="margin-left:86px;" @click="linkToWorkRecord(revokeList1,'4')">回访登记</Button>
            </div>
          </i-col>
        </Row>
        <Row style="margin-bottom:20px;">
          <i-col span="3">工作地点：</i-col>
          <i-col span="12">
            <div>{{revokeList1.workSite}}</div>
          </i-col>
        </Row>
        <Row style="margin-bottom:20px;">
          <i-col span="3">工作内容：</i-col>
          <i-col span="18">
            <!-- <div style="max-height:84px; overflow-x:hidden;"> -->
            <!-- <div class="omit">{{revokeList1.expectEffect.expectEffect}}</div> -->
            <!-- {{revokeList1.expectEffect[0].expectEffect}} -->
            <!-- <div class="omit" v-for ="(item,index) in revokeList1.expectEffect" :key="index">{{index+1}} 、{{item.expectEffect}}</div> -->
             <div class="omit" v-for ="(item,index) in revokeList1.expectEffect" :key="index">{{index+1}} 、{{item.expectEffect}}</div>
          </i-col>
        </Row>
        <Row style="margin-bottom:20px;">
          <i-col span="3">说明附件：</i-col>
          <i-col span="18">
            <!-- <div style="max-height:84px; overflow-x:hidden;"> -->
            <div>
              <div v-if="revokeList1.smallFile != '暂无附件'">
                <p
                  v-for="(item,index) in revokeList1.files"
                  :key="index"
                  class="see-btn omit"
                  @click="checkFile(item)"
                >{{item[1]}}</p>
              </div>
              <p v-if="revokeList1.smallFile == '暂无附件'">暂无附件</p>
            </div>
          </i-col>
        </Row>

      </div>
        <div class="start">
          <div class="start-title">评&nbsp;&nbsp;&nbsp;&nbsp;价:</div>
          <div style="width:100%; margin:0 0 20px 60px;">
            <Row>
              <i-col span="20">
                <i-col span="24" v-if="assessList.length>0">
                  <Row class="assess-t" v-for="(item,index) in assessList" :key="index">
                    <i-col span="5">
                      <p class="start-body-title">{{item.name}}评价:</p>
                    </i-col>
                    <i-col span="8">
                      <Rate v-model="item.stars" disabled />
                    </i-col>
                    <i-col span="7">
                      <p class="start-body-title">{{item.createTime}}</p>
                    </i-col>
                    <i-col span="3" v-if="item.reagentCode==userId">
                      <Button class="com-del-btn" @click="commendDel(item)">删除</Button>
                    </i-col>
                    <i-col span="24" style="margin-bottom:10px;color: #c6c7c8;word-wrap: break-word;">点评内容：{{item.detail}}</i-col>


                    <!-- 回复列表 -->
                    <div v-for="(innerItem, index) in item.replayList" :key="index" style="margin-left:10px;" class="ivu-row">
                      <i-col span="4">
                        <p class="start-body-title">{{innerItem.name}}回复:</p>
                      </i-col>
                      <i-col span="9">
                        <Rate value=5 disabled />
                      </i-col>
                      <i-col span="7">
                        <p class="start-body-title">{{innerItem.createTime}}</p>
                      </i-col>
                      <i-col span="4" v-if="innerItem.reagentCode==userId">
                        <Button class="com-del-btn" @click="commentDel(innerItem, index, item)">删除</Button>
                      </i-col>
                      <i-col span="24" style="margin-bottom:10px;color: #c6c7c8;word-wrap: break-word;">回复内容：{{innerItem.detail}}</i-col>

                    </div>
                  </Row>
                </i-col>
                <i-col span="18" v-else>
                  <Row style="margin-top:20px;">
                    <i-col span="24" style="height:20px;line-height:20px;">暂无评价</i-col>
                  </Row>
                </i-col>
              </i-col>
            </Row>
            <Row style="margin-top:20px;">
              <i-col span="18">
                <i-input v-model="rateForm.rateAssess" placeholder="请输入点评内容" clearable>
                  <span slot="prepend">
                    <Rate v-model="rateForm.value" />
                  </span>
                </i-input>
              </i-col>
              <i-col span="2">
                <Button type="primary" @click="submitRate()">提交</Button>
              </i-col>
            </Row>
          </div>
        </div>
    </Modal>
     <!--回退框  -->
     <Modal v-model="retreatShow" footer-hide="true" :mask-closable="false">
      <div slot="header" class="draftTitle">退回详情</div>
      <div>
        <Form ref="retreatForm" :model="retreatForm" :rules="retreatRules" :label-width="80">
          <FormItem label="退回原因" prop="cause">
            <Input v-model="retreatForm.cause" type="textarea" :autosize="{ minRows: 5, maxRows: 5 }"
              placeholder="输入退回原因" :maxlength="200"></Input>
          </FormItem> 
        </Form>
        <Row style="margin-bottom:20px; margin-top:10px;" type="flex" justify="center" :gutter="120">
          <i-col>
            <Button type="primary" @click="retreat('retreatForm')">确定</Button>
          </i-col>
          <i-col>
            <Button @click="retreatCancel('retreatForm')">取消</Button>
          </i-col>
        </Row>
      </div>
    </Modal>
    <!-- 详情————已回销 -->
    <Modal v-model="modal2" :transfer="false"   footer-hide="true" :mask-closable="false" width="680px" class="edModal" @on-cancel="cancelWin()">
      <div slot="header" class="draftTitle">工作日志详情</div>
      <div>
        <Row style="margin-bottom:20px; margin-top:10px;">
          <i-col span="4" class="user-title" style="margin-right:10px;">{{infoList.name}}</i-col>
          <i-col span="4" class="user-list">
            <Icon type="md-browsers" />
            {{infoList.employeeNO}}
          </i-col>
          <i-col span="4" class="user-list">
            <Icon type="md-person" />
            {{infoList.roleName}}
          </i-col>
          <i-col span="10" class="user-list">
            <Icon type="ios-pin" />
            {{infoList.managecomName}}
          </i-col>
        </Row>
        <div class="ar-title">工作日志制定详情:</div>
        <div style="width:100%; margin:0 0 20px 60px;">
          <Row style="margin-bottom:20px; margin-top:20px;">
            <i-col span="3">工作类型：</i-col>
            <i-col span="12">
              <div>{{revokeList1.workType}}</div>
            </i-col>
          </Row>
          <Row style="margin-bottom:20px;">
            <i-col span="3">工作时间：</i-col>
            <i-col span="12">
              <div v-if="revokeList1.workBegin">{{revokeList1.workBegin.workDay}} {{revokeList1.workBegin.workTime}}</div>
            </i-col>
          </Row>
          <Row style="margin-bottom:20px;">
            <i-col span="3">电访情况：</i-col>
            <i-col span="12">
              <div>
                <span>计划{{revokeList1.detailNum ? revokeList1.detailNum.planphonecount : 0}}单-完成{{revokeList1.detailNum ? revokeList1.detailNum.donephonecount : 0}}单-超期{{revokeList1.detailNum ? revokeList1.detailNum.delayphonecount : 0}}单</span>
                <Button type="primary" size="small" style="margin-left:5px;" @click="linkToWorkRecord(revokeList1,'0')">工作记录</Button>
              </div>
            </i-col>
          </Row>
          <Row style="margin-bottom:20px;">
            <i-col span="3">面访情况：</i-col>
            <i-col span="12">
              <div>
                <span>计划{{revokeList1.detailNum ? revokeList1.detailNum.plantalkcount : 0}}单-完成{{revokeList1.detailNum ? revokeList1.detailNum.donetalkcount : 0}}单-超期{{revokeList1.detailNum ? revokeList1.detailNum.delaytalkcount : 0}}单</span>
                <Button type="primary" size="small" style="margin-left:5px;" @click="linkToWorkRecord(revokeList1,'1')">工作记录</Button>
              </div>
            </i-col>
          </Row>
          <Row style="margin-bottom:20px;">
            <i-col span="3">短信情况：</i-col>
            <i-col span="12">
              <div>
                <span>计划{{revokeList1.detailNum ? revokeList1.detailNum.planmessagecount : 0}}单-完成{{revokeList1.detailNum ? revokeList1.detailNum.donemessagecount : 0}}单-超期{{revokeList1.detailNum ? revokeList1.detailNum.delaymessagecount : 0}}单</span>
                <Button type="primary" size="small" style="margin-left:5px;" @click="linkToWorkRecord(revokeList1,'2')">工作记录</Button>
              </div>
            </i-col>
          </Row>
          <Row style="margin-bottom:20px;">
            <i-col span="3">网络情况：</i-col>
            <i-col span="12">
              <div>
                <span>计划{{revokeList1.detailNum ? revokeList1.detailNum.plannetcount : 0}}单-完成{{revokeList1.detailNum ? revokeList1.detailNum.donenetcount : 0}}单-超期{{revokeList1.detailNum ? revokeList1.detailNum.delaynetcount : 0}}单</span>
                <Button type="primary" size="small" style="margin-left:5px;" @click="linkToWorkRecord(revokeList1,'3')">工作记录</Button>
              </div>
            </i-col>
          </Row>
          <Row style="margin-bottom:20px;">
            <i-col span="3">续期情况：</i-col>
            <i-col span="12">
              <div>
                <span>收费成功{{revokeList1.detailNum ? revokeList1.detailNum.donefeecount : 0}}单</span>
                <Button type="primary" size="small" style="margin-left:86px;" @click="linkToWorkRecord(revokeList1,'4')">回访登记</Button>
              </div>
            </i-col>
          </Row>
          <Row style="margin-bottom:20px;">
            <i-col span="3">工作地点：</i-col>
            <i-col span="12">
              <div v-if="revokeList1.workBegin">{{revokeList1.workBegin.workSite}}</div>
            </i-col>
          </Row>
          <Row style="margin-bottom:20px;">
            <i-col span="3">工作内容：</i-col>
            <i-col span="18">
              <!-- <div style="max-height:84px; overflow-x:hidden;"> -->
              <!-- <div class="omit">{{revokeList1.expectEffect}}</div> -->
              <div class="omit" v-for ="(item,index) in revokeList2.expectEffect" :key="index">{{index+1}} 、{{item.expectEffect}}</div>
            </i-col>
          </Row>
          <Row style="margin-bottom:20px;">
            <i-col span="3">说明附件：</i-col>
            <i-col span="18">
              <!-- <div style="max-height:84px; overflow-x:hidden;"> -->
              <div>
                <div v-if="revokeList1.smallFile != '暂无附件'">
                  <p
                    v-for="(item,index) in revokeList1.filesA"
                    :key="index"
                    class="see-btn omit"
                    @click="checkFile(item)"
                  >{{item[1]}}</p>
                </div>
                <p v-if="revokeList1.smallFile == '暂无附件'">暂无附件</p>
              </div>
            </i-col>
          </Row>
        </div>
        <!-- </div> -->
        <div class="line"></div>
        <div class="ar-title">工作日志回销详情:</div>
        <div style="width:100%; margin:0 0 20px 60px;">
          <Row style="margin-bottom:20px; margin-top:20px;">
            <i-col span="3">工作类型：</i-col>
            <i-col span="12">
              <div>{{revokeList2.workType}}</div>
            </i-col>
          </Row>
          <Row style="margin-bottom:20px;">
            <i-col span="3">工作时间：</i-col>
            <i-col span="12">
              <div>{{revokeList2.workDay}} {{revokeList2.workTime}}</div>
            </i-col>
          </Row>
          <Row style="margin-bottom:20px;">
            <i-col span="3">工作地点：</i-col>
            <i-col span="12">
              <div>{{revokeList2.workSite}}</div>
            </i-col>
          </Row>
          <Row style="margin-bottom:20px;">
            <i-col span="3">完成情况：</i-col>
            <i-col span="18">
              <!-- <div style="max-height:84px; overflow-x:hidden;"> -->
              <!-- <div class="omit">{{revokeList2.expectEffect}}</div> -->
               <div class="omit" v-for ="(item,index) in revokeList1.diaryA" :key="index">{{index+1}} 、{{item.expectEffect}}</div>
            </i-col>
          </Row>
          <Row style="margin-bottom:20px;">
            <i-col span="3">说明附件：</i-col>
            <i-col span="18">
              <!-- <div style="max-height:84px; overflow-x:hidden;"> -->
              <div>
                <div v-if="revokeList2.smallFile != '暂无附件'">
                  <p
                    v-for="(item,index) in revokeList2.files"
                    :key="index"
                    class="see-btn omit"
                    @click="checkFile(item)"
                  >{{item[1]}}</p>
                </div>
                <p v-if="revokeList2.smallFile == '暂无附件'">暂无附件</p>
              </div>
            </i-col>
          </Row>
        </div>
        <div class="start">
          <div class="start-title">评&nbsp;&nbsp;&nbsp;&nbsp;价:</div>
          <div style="width:100%; margin:0 0 20px 60px;">
            <Row>
              <i-col span="20">
                <i-col span="24" v-if="assessList.length>0">
                  <!-- <Row class="assess-t" v-for="(item,index) in assessList" :key="index">
                    <i-col span="5">
                      <p class="start-body-title">{{item.name}}评价:</p>
                    </i-col>
                    <i-col span="9">
                      <Rate v-model="item.stars" disabled />
                    </i-col>
                    <i-col span="8" style="margin-top:5px;">{{item.detail}}</i-col>
                    <i-col span="2" v-if="item.reagentCode==userId">
                      <Button class="com-del-btn" @click="commendDel(item)">删除</Button>
                    </i-col>
                  </Row> -->
                  <Row class="assess-t" v-for="(item,index) in assessList" :key="index">
                    <i-col span="5">
                      <p class="start-body-title">{{item.name}}评价:</p>
                    </i-col>
                    <i-col span="8">
                      <Rate v-model="item.stars" disabled />
                    </i-col>
                    <i-col span="7">
                      <p class="start-body-title" style="font-size:12px;">{{item.createTime}}</p>
                    </i-col>
                    <i-col span="3" v-if="item.reagentCode==userId">
                      <Button class="com-del-btn" @click="commendDel(item)">删除</Button>
                    </i-col>
                    <i-col span="24" style="margin-bottom:10px;color: #c6c7c8;word-wrap: break-word;">点评内容：{{item.detail}}</i-col>

                    <!-- 回复列表 -->
                    <div v-for="(innerItem, index) in item.replayList" :key="index" style="margin-left:10px;" class="ivu-row">
                      <i-col span="4">
                        <p class="start-body-title">{{innerItem.name}}回复:</p>
                      </i-col>
                      <i-col span="9">
                        <Rate value=5 disabled />
                      </i-col>
                      <i-col span="7">
                        <p class="start-body-title">{{innerItem.createTime}}</p>
                      </i-col>
                      <i-col span="4" v-if="innerItem.reagentCode==userId">
                        <Button class="com-del-btn" @click="commentDel(innerItem, index, item)">删除</Button>
                      </i-col>
                      <i-col span="24" style="margin-bottom:10px;color: #c6c7c8;word-wrap: break-word;">回复内容：{{innerItem.detail}}</i-col>

                    </div>

                  </Row>
                </i-col>
                <i-col span="18" v-else>
                  <Row style="margin-top:20px;">
                    <i-col span="24" style="height:20px;line-height:20px;">暂无评价</i-col>
                  </Row>
                </i-col>
              </i-col>
            </Row>
            <Row style="margin-top:20px;">
              <i-col span="18">
                <i-input v-model="rateForm.rateAssess" placeholder="请输入点评内容" clearable>
                  <span slot="prepend">
                    <Rate v-model="rateForm.value" />
                  </span>
                </i-input>
              </i-col>
              <i-col span="2">
                <Button type="primary" @click="submitRate()">提交</Button>
              </i-col>
            </Row>
            <Row style="margin-top:20px;" v-if="rowState == '已回销'">
              <i-col span="2">
                <Button type="primary" @click="toRetreat()">回退</Button>
              </i-col>
            </Row>
          </div>
        </div>
      </div>
    </Modal>

    <!-- 播放视频 -->
    <Modal
      footer-hide="true"
      :value="videoModal"
      :mask-closable="true"
      @on-visible-change="modalVisibleChange"
      :closable="false"
    >
      <span class="photoModal">
        <video :src="photoItem" controls id="video1" controlslist="nodownload" />
      </span>
    </Modal>
    <Button type="primary" @click="info" v-if="false"></Button>
  </div>
</template>

<script>
import {exportFile} from "../../../util/util"
export default {
  name: 'workLogEvaluation',
  data() {
    return {
      rowState:'',
      btn: ["primary", "default", "default"],
      queryForm: {
        managecome: null,
        reagentCode: [],
        workNews: null,
        workDate: ["", ""]
      },
      organizationList: [],
      reagentNameList: [],
      newsList: [
        { key: "1", value: "日报" },
        { key: "2", value: "宣导计划" },
        { key: "3", value: "服务计划" },
        { key: "4", value: "业务操作" },
        { key: "5", value: "其他" }
      ],
      roleValidate: {
        managecome: [
          { required: true, type:"array", message: "续期专员机构不能为空", trigger: "change" }
        ]
      },
      retreatRules: { cause: [{ required: true, message: '输入退回原因', trigger: 'blur' }] },
      queryLoading: false,
      evaluationList: [],
      modal1: false,
      modal2: false,
      // 分页
      total: 0,
      pageSize: 8,
      pageIndex: 1,
      pageObj: null,
      statusObj: null,
      // 详情 -- 未回销
      revokeList1: [],
      // 详情 -- 已回销
      revokeList2: [],
      // 评价
      assessList: [],
      // 个人信息
      infoList: [],
      // 登陆者工号
      userId: null,
      // 评价输入
      rateForm: {
        rateAssess: null,
        value: 0
      },
      dustyId: null,
      videoModal: false,
      currentId: "",
      currentIdx: "",
      // 回退框
      retreatShow: false,
      retreatForm: {
        cause: null
      }
    };
  },
  methods: {
    //清空
    cancelWin(){
      this.rateForm.rateAssess = "";
      this.rateForm.value = "";
    },
    //跳转去工作记录
    linkToWorkRecord(n,type){
      sessionStorage.setItem("workRecordQueryForm",JSON.stringify(this.queryForm))
      // this.$router.push({
      //   name: "workRecordCheckingList",
      //   query: {
      //     row: n,
      //     reagentCode:n.reagentCode,
      //     appointeddate:n.workDay,
      //     type:type
      //   }
      // });
      // this.modal1 = false
      // this.modal2 = false
      window.sessionStorage.setItem("flag","1")
      if(type != "4"){
        this.$router.push({
          // name: "workRecordCheckingList",
          path: "workRecordCheckingList",
          query: {
            row: n,
            reagentCode:n.reagentCode,
            appointeddate:n.makeDay,
            type:type,
            flag:"1"
          }
        });
      }else{
        this.$router.push({
          // name: "workRecordReturnList",
          path: "workRecordReturnList",
          query: {
            row: n,
            reagentCode:n.reagentCode,
            appointeddate:n.makeDay,
            type:type,
            flag:"1"
          }
        });
      }
    },
    info(tip) {
      this.$Message.info(tip);
    },
    // 日期变化时
    workDateChange(chooseDate, currentDate) {
      this.queryForm.workDate = chooseDate;
    },
    //转时间
    timeFormat(time){
      if(!time){
        return ''
      }
      let d = new Date(time)
      var y = d.getFullYear();         
      var m = d.getMonth() + 1;         
      if(m < 10) {          
        m = "0" + m;          
      }         
      var day = d.getDate();         
      if(day < 10) {          
        day = "0" + day;          
      } 
      return y + "-" + m + "-" + day;
    },
    //获取续期机构
    getorganizationList(n) {
      this.api.remanagecomList().then(res => {
        if (res.code == 200 && res.data != null) {
          let arr = []
          arr.push(res.data)
          arr.forEach(one=>{
            one.value = one.comcode
            one.label = one.comcode + '-' + one.name
            one.children = one.chilDren || []
            if (one.children) {
              one.chilDren.forEach(two=>{
                two.value = two.comcode
                two.label = two.comcode + '-' + two.name
                two.children = two.chilDren || []
                if (two.children) {
                  two.children.forEach(three=>{
                    three.value = three.comcode
                    three.label = three.comcode + '-' + three.name
                    three.children = three.chilDren || []
                    if (three.children) {
                      three.children.forEach(four=>{
                        four.value = four.comcode
                        four.label = four.comcode + '-' + four.name
                        four.children = four.chilDren || []
                      })
                    }
                  })
                }
              })
            }
          })
          console.log(arr);
          this.organizationList = arr
        } else {
          this.organizationList = [];
        }
      });
      // this.api.selectUerList().then(res => {
      //   if (res.code == 200 && res.data != null) {
      //     // this.organizationList = res.data[0].listKeyValueVOS;
      //     if(n){
      //       if(sessionStorage.getItem("workRecordQueryForm")){
      //         let sessData = sessionStorage.getItem("workRecordQueryForm")

      //         this.queryForm = sessData ? JSON.parse(sessData) : {}

      //         // sessionStorage.removeItem("workRecordQueryForm")
      //         this.organizationChange(this.queryForm.managecome)
      //         // this.submitForm()
      //       }
      //     }
      //   } else {
      //     this.organizationList = [];
      //   }
      // });
    },
    // 获取续期人员
    organizationChange(value) {
      if (!value) {
        this.reagentNameList = [];
      } else {
        this.api.selectXQCode({ managecom: value[value.length-1] }).then(res => {
          if (res.code == 200) {
            if (res.data) {
              this.reagentNameList = res.data;
              if(sessionStorage.getItem("workRecordQueryForm")){
                this.submitForm()
                sessionStorage.removeItem("workRecordQueryForm")
              }
            } else {
              this.reagentNameList = [];
            }
            // console.log(res);
          } else {
            this.reagentNameList = [];
            this.$Message.info(res.msg);
          }
        });
      }
    },
    //查询
    submitForm() {
      console.log("123")
      this.pageIndex = 1;
      this.btn = ["primary", "default", "default"];
      this.$refs.queryForm.validate(valid => {
        if (valid) {
          this.queryLoading = true;
          this.evaluationList = [];
          let startDay = null;
          let endDay = null;
          if (this.queryForm.workDate[0] != "") {
            startDay = this.timeFormat( this.queryForm.workDate[0]);
            endDay = this.timeFormat(this.queryForm.workDate[1]);
            this.queryForm.workDate[0] = this.timeFormat( this.queryForm.workDate[0]);
            this.queryForm.workDate[1] = this.timeFormat( this.queryForm.workDate[1]);
          }

          let obj = {
            workType: this.queryForm.workNews,
            workBeginDay: startDay,
            workEndDay: endDay,
            status: null,
            managecom: this.queryForm.managecome[this.queryForm.managecome.length-1],
            reagentCode: this.queryForm.reagentCode + "",
            index: 1,
            pageSize: this.pageSize
          };
          // console.log(obj)
          this.pageObj = obj;
          this.statusObj = obj;

          this.api.selectWorkDiary(obj).then(res => {
            if (res.code == 200) {
              if (res.data.records) {
                // this.evaluationList = res.data.records;
                res.data.records.forEach(element => {
                  element["smallFile"] = "";
                  if (element.files) {
                    if (element.files.length > 0) {
                      if (element.files.length == 1) {
                        element["smallFile"] = element.files[0][1];
                      } else {
                        for (let m = 0; m < element.files.length; m++) {
                          if (m < element.files.length - 1) {
                            element["smallFile"] += element.files[m][1] + "、";
                          } else {
                            element["smallFile"] += element.files[m][1];
                          }
                        }
                      }
                    } else {
                      element["smallFile"] = "暂无附件";
                    }
                  }
                  this.evaluationList.push(element);
                });
                this.DustyQuery()
                this.total = res.data.total;
                this.queryLoading = false;
                this.info(res.msg);
              } else {
                this.info("暂无数据！");
                this.evaluationList = [];
                this.queryLoading = false;
              }
            } else {
              this.info(res.msg);
              this.evaluationList = [];
              this.queryLoading = false;
            }
          });
        }
      });
    },
    
    // 重置
    resetForm() {
      this.$refs.queryForm.resetFields();
    },
    // 分页查询
    pageChange(pageIndex) {
      this.pageIndex = pageIndex;
      this.submitPage();
    },
    submitPage() {
      this.pageObj.index = this.pageIndex;
      this.evaluationList = [];
      this.api.selectWorkDiary(this.pageObj).then(res => {
        if (res.code == 200) {
          if (res.data.records) {
            // this.evaluationList = res.data.records;
            res.data.records.forEach(element => {
              element["smallFile"] = "";
              if (element.files) {
                if (element.files.length > 0) {
                  if (element.files.length == 1) {
                    element["smallFile"] = element.files[0][1];
                  } else {
                    for (let m = 0; m < element.files.length; m++) {
                      if (m < element.files.length - 1) {
                        element["smallFile"] += element.files[m][1] + "、";
                      } else {
                        element["smallFile"] += element.files[m][1];
                      }
                    }
                  }
                } else {
                  element["smallFile"] = "暂无附件";
                }
              }

              this.evaluationList.push(element);
            });
            this.DustyQuery()


            this.total = res.data.total;
          } else {
            this.info("暂无数据！");
            this.evaluationList = [];
          }
        } else {
          this.info(res.msg);
          this.evaluationList = [];
        }
      });
    },
    // 全部->未回销->已回销------切换
    buttonClick(idx) {
      this.evaluationList = [];
      this.statusObj.index = 1;
      if (idx == 0) {
        // 全部
        this.btn = ["primary", "default", "default"];
        this.statusObj.status = null;
        this.api.selectWorkDiary(this.statusObj).then(res => {
          if (res.code == 200) {
            if (res.data.records) {
              res.data.records.forEach(element => {
                element["smallFile"] = "";
                if (element.files) {
                  if (element.files.length > 0) {
                    if (element.files.length == 1) {
                      element["smallFile"] = element.files[0][1];
                    } else {
                      for (let m = 0; m < element.files.length; m++) {
                        if (m < element.files.length - 1) {
                          element["smallFile"] += element.files[m][1] + "、";
                        } else {
                          element["smallFile"] += element.files[m][1];
                        }
                      }
                    }
                  } else {
                    element["smallFile"] = "暂无附件";
                  }
                }

                this.evaluationList.push(element);
              });
              this.DustyQuery()
              this.total = res.data.total;
            } else {
              this.info("暂无数据！");
              this.evaluationList = [];
            }
          } else {
            this.info(res.msg);
            this.evaluationList = [];
          }
        });
      } else if (idx == 1) {
        // 未回销
        this.btn = ["default", "primary", "default"];
        this.statusObj.status = "1";
        this.api.selectWorkDiary(this.statusObj).then(res => {
          if (res.code == 200) {
            if (res.data.records) {
              res.data.records.forEach(element => {
                element["smallFile"] = "";
                if (element.files) {
                  if (element.files.length > 0) {
                    if (element.files.length == 1) {
                      element["smallFile"] = element.files[0][1];
                    } else {
                      for (let m = 0; m < element.files.length; m++) {
                        if (m < element.files.length - 1) {
                          element["smallFile"] += element.files[m][1] + "、";
                        } else {
                          element["smallFile"] += element.files[m][1];
                        }
                      }
                    }
                  } else {
                    element["smallFile"] = "暂无附件";
                  }
                }

                this.evaluationList.push(element);
              });
              this.DustyQuery()
              this.total = res.data.total;
            } else {
              this.info("暂无数据！");
              this.evaluationList = [];
            }
          } else {
            this.info(res.msg);
            this.evaluationList = [];
          }
        });
      } else {
        // 已回销
        this.btn = ["default", "default", "primary"];
        this.statusObj.status = "2";
        this.api.selectWorkDiary(this.statusObj).then(res => {
          if (res.code == 200) {
            if (res.data.records) {
              res.data.records.forEach(element => {
                element["smallFile"] = "";
                if (element.files) {
                  if (element.files.length > 0) {
                    if (element.files.length == 1) {
                      element["smallFile"] = element.files[0][1];
                    } else {
                      for (let m = 0; m < element.files.length; m++) {
                        if (m < element.files.length - 1) {
                          element["smallFile"] += element.files[m][1] + "、";
                        } else {
                          element["smallFile"] += element.files[m][1];
                        }
                      }
                    }
                  } else {
                    element["smallFile"] = "暂无附件";
                  }
                }

                this.evaluationList.push(element);
              });
              this.DustyQuery()
              this.total = res.data.total;
            } else {
              this.info("暂无数据！");
              this.evaluationList = [];
            }
          } else {
            this.info(res.msg);
            this.evaluationList = [];
          }
        });
      }
    },
    // 批量导出
    downLoad1() {
      // let url =
      //   "../rest/export/uerWorkDiaryExport?managecom=" +
      //   this.statusObj.managecom;
      // if (this.statusObj.reagentCode.length > 0) {
      //   url = url + "&reagentCode=" + this.statusObj.reagentCode;
      // }
      // if (this.statusObj.status != null) {
      //   url = url + "&status=" + this.statusObj.status;
      // }
      // if (this.statusObj.workType != null) {
      //   url = url + "&workType=" + this.statusObj.workType;
      // }
      // if (this.statusObj.workBeginDay != null) {
      //   url =
      //     url +
      //     "&workBeginDay=" +
      //     this.statusObj.workBeginDay +
      //     "&workEndDay=" +
      //     this.statusObj.workEndDay;
      // }
      // // console.log(url);
      // window.open(url);
      let newreagentCode = this.statusObj.reagentCode?this.statusObj.reagentCode.split(','):[]
      let obj = {
        managecom:this.statusObj.managecom,
        reagentCode:newreagentCode||[],
        status:this.statusObj.status,
        workType:this.statusObj.workType,
        workBeginDay:this.statusObj.workBeginDay,
        workEndDay:this.statusObj.workEndDay,
      }
      exportFile("scrm-gateway/scrm-uer/api/export/uerWorkDiaryExport",obj)

    },
    // 回销详情
    logDetail(row, index) {
      this.rowState = row.status;
      this.currentId = row.id;
      this.currentIdx = index;
      this.infoList = [];
      this.assessList = [];
      // 日志个人信息
      this.api.getUserByNo({ no: row.reagentCode }).then(res => {
        if (res.code == 200 && res.data != null) {
          this.infoList = res.data;
        } else {
          this.info(res.msg);
        }
      });
      if (row.status == "未回销") {
        this.revokeList1 = row;
        this.revokeList1.detailNum = row.detailNum
        this.dustyId = row.dustyId;
        this.getAssessList();
        this.modal1 = true;
        // console.log("000000"+row.dustyId)
      } else {
        let obj = {
          dustyId: row.dustyId,
          id:row.id
        }
        //已回销时的详情
        this.api.getOneWorkDiary(obj).then(res => {
          if (res.code == 200) {
            if (res.data != null) {
              console.log(res.data,"*********");
              this.revokeList1 = res.data;
              this.revokeList1.detailNum = row.detailNum
              // let t = Number(this.revokeList1.workType) - 1;
              // this.revokeList1.workType = this.newsList[t].value;
              // this.revokeList1.workBegin
              this.newsList.forEach(item=>{
                if(item.key == res.data.workType){
                  this.revokeList1.workType = item.value
                }
                if(item.key == res.data.workBegin.workType){
                  this.revokeList1.workBegin.workType = item.value
                }
              })
              if (!this.revokeList1.filesA[0]) {
                this.revokeList1["smallFile"] = "暂无附件";
              } else {
                console.log(this.revokeList1.filesA,"***********");
                this.revokeList1["smallFile"] = this.revokeList1.filesA;
              }
            }
          } else {
            this.info(res.msg);
          }
        });
        //工作日志回销详情:
        this.revokeList2 = row;
        // 领导评价
        this.getAssessList();
        this.modal2 = true;
      }
    },
    // 评价提交
    async submitRate() {
      if(!this.rateForm.value && !this.rateForm.rateAssess){
        this.info("点评星级和点评内容不能同时为空");
        return;
      }
      let rateList = {
        aId: this.currentId,
        dustyId: this.dustyId,
        reagentCode: this.userId,
        stars: this.rateForm.value,
        detail: this.rateForm.rateAssess,
        backflag: this.rowState=="未回销" ? "1" : "0"
      };
      this.api.addWorkDiaryEstimate(rateList).then(res => {
        if (res.code == 200) {
          this.rateForm.rateAssess = null;
          this.rateForm.value = 0;
          this.evaluationList[this.currentIdx].isRead = "0";
          // let resassess = await this.getAssessList();


          this.assessList = [];
          let newParm = {
            dustyId: this.dustyId,
            aId: this.currentId
          }
          this.api.selectWorkDiaryEstimate(newParm).then(res => {
            if (res.code == 200) {
              if (res.data) {
                if (res.data.length > 0) {
                  this.assessList = res.data;
          console.log(this.assessList[this.assessList.length-1],this.assessList.length)
          //2020-12-15 用于触发弹窗
          this.api.sendNotice({
            agentcode:this.infoList.employeeNO,
            messageid:this.infoList.id,
            messagetype:1,
          }).then(res => {
            console.log(res)
          })
          // console.log(this.assessList,this.assessList.length)
          this.api.pushOneUser({
            agentCode: this.infoList.employeeNO,
            templateType: 2,
            // id: this.infoList.id,
            id: this.currentId,
            estimateid: this.assessList[this.assessList.length-1].id
          }).then(res => {
            console.log(res)
          })


                  this.assessList.forEach(element => {
                    element.stars = Number(element.stars);

                    // element.showReplayEdit = false;
                    // element.replayDetail = "";
                    //回复数据
                    this.api.selectWorkEstimateReplay({ estimateId: element.id }).then(res => {
                      if (res.code == 200) {
                        //待联调
                        element.replayList = res.data;
                        this.$forceUpdate();
                        // console.log(element.replayList)

                      }else{
                        this.info("查询回复失败");
                      }
                    })


                  });
                }
              } else {
                this.assessList = [];
                this.evaluationList[this.currentIdx].isRead = "";
              }
            } else {
              this.assessList = [];
              this.info(res.msg);
            }
          });





        } else {
          this.info(res.msg);
        }
      });
    },
    // 评价删除
    commendDel(row) {
      let newParm = {
        dustyId: row.id,
        aId: this.currentId
      }
      this.api.delWorkDiaryEstimate(newParm).then(res => {
        if (res.code == 200) {
          this.getAssessList();
          this.info(res.msg);
        } else {
          this.info(res.msg);
        }
      });
    },
    // 领导评价
    getAssessList() {
      this.assessList = [];
      let newParm = {
        dustyId: this.dustyId,
        aId: this.currentId
      }
      this.api.selectWorkDiaryEstimate(newParm).then(res => {
        if (res.code == 200) {
          if (res.data) {
            if (res.data.length > 0) {
              this.assessList = res.data;
              this.assessList.forEach(element => {
                element.stars = Number(element.stars);

                // element.showReplayEdit = false;
                // element.replayDetail = "";
                //回复数据
                this.api.selectWorkEstimateReplay({ estimateId: element.id }).then(res => {
                  if (res.code == 200) {
                    //待联调
                    element.replayList = res.data;
                    this.$forceUpdate();
                    // console.log(element.replayList)


                  }else{
                    this.info("查询回复失败");
                  }
                })


              });
            }
          } else {
            this.assessList = [];
            this.evaluationList[this.currentIdx].isRead = "";
          }
        } else {
          this.assessList = [];
          this.info(res.msg);
        }
      });
    },

    // 关闭视频弹窗
    modalVisibleChange(value) {
      if (!value) {
        this.videoModal = false;
        let video1 = document.getElementById("video1");
        video1.pause();
      }
    },

    //查看或播放
    checkFile(item) {
      let typeFg = item[1].split(".");
      typeFg = typeFg[typeFg.length - 1];
      // console.log(typeFg);
      if (typeFg == "pdf") {
        // 查看PDF
        let url = item[3];
        window.open(url + "#toolbar=0");
      } else if(typeFg == "mp4") {
        // 播放视频
        this.videoModal = true;
        this.photoItem = item[3];
      } else {
        let url = item[3];
        window.open(url)
        console.log(item)
      }
    },
    DustyQuery(){
      for(let i=0;i<this.evaluationList.length;i++){
      let parm = {
        reagentcode: this.evaluationList[i].reagentCode,
        appointeddate: this.evaluationList[i].makeDay
      }
      // this.api.selectWorkDoneState(parm).then(res => {
      //   if (res.code == 200) {
      //     if (res.data) {
      //       this.evaluationList[i].detailNum = res.data
      //       this.$forceUpdate();
      //     }
      //   }
      // });
    }
    },
    // 点击回退
    toRetreat() {
      this.retreatShow = true
    },
    // 取消
    retreatCancel(name) {
      this.$refs[name].resetFields();
      this.retreatShow = false
    },
    // 确认回退
    retreat(name) {
      this.$refs[name].validate((valid) => {
        if (valid) {
          let obj = {
            returnId:this.revokeList2.id,
            agentcode:this.userId,
            cause:this.retreatForm.cause,
            dustyId:this.revokeList2.dustyId
          }
          this.api.returnWorkDiary(obj).then(res=>{
            if (res.code == 200) {
              this.submitForm()
              this.$Message.success(res.data);
              this.retreatShow = false
              this.$refs.retreatForm.resetFields();
              this.modal2 = false
            } else {
              this.$Message.error(res.msg);
              this.retreatShow = false
            }
          })
        } else {
          // this.$Message.error('Fail!');
        }
      })
    },
  },
  mounted() {


    this.userName = sessionStorage.getItem("name");
    this.userId = sessionStorage.getItem("useragentcode");
    this.getorganizationList();


  }
};
</script>

<style lang="less" scoped>
@import "./index";
</style>


<style lang="less">
.ivu-modal-header {
  background-color: #2d8cf0;
}

.ivu-icon-ios-close:before,
.ivu-modal-close .ivu-icon-ios-close {
  color: white !important;
}

.code-LC {
  .ivu-icon-ios-close:before,
  .ivu-modal-close .ivu-icon-ios-close {
    color: black !important;
  }
}

.edModal .ivu-modal-body {
  max-height: 500px;
  overflow-x: hidden;
}

.examCard .ivu-card-extra {
  width: 100%;
  position: absolute;
  top: 0;
  right: 0;
}
</style>
